from django.shortcuts import render
from .serializer import AppealsSerializer
from rest_framework import viewsets
from .models import Appeals
from .serializer import AppealsSerializer, AppealDetailSerializer
# Create your views here.

class AppealViewSet(viewsets.ModelViewSet):
    serializer_class = AppealsSerializer
    def get_queryset(self):
        queryset = Appeals.objects.all()
        params = self.request.query_params
        if params:
            filters = {}
            for key, value in params.items():
                filters[key] = value
            queryset = queryset.filter(**filters)
        return queryset
    
class AppealDetailViewSet(viewsets.ModelViewSet):
    serializer_class = AppealDetailSerializer
    def get_queryset(self):
        queryset = Appeals.objects.all()
        params = self.request.query_params
        if params:
            filters = {}
            for key, value in params.items():
                filters[key] = value
            queryset = queryset.filter(**filters)
        return queryset
        
